package com.bw.park2301.fragment

import android.os.Bundle
import android.util.Log
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import com.bw.lib_base.entity.NoticeBeanItem
import com.bw.lib_base.mvvm.BaseFragment
import com.bw.park2301.R
import com.bw.park2301.databinding.FragmentHomeBinding
import com.bw.park2301.notice.NoticeAdapter
import com.bw.park2301.notice.NoticeViewModel
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.launch

@AndroidEntryPoint
class HomeFragment : BaseFragment<FragmentHomeBinding,NoticeViewModel>() {
    val noticeAdapter by lazy { NoticeAdapter(binding.rv) }
    override fun initView() {
        binding.rv.apply {
            adapter = noticeAdapter
            layoutManager = LinearLayoutManager(requireContext())
        }

        lifecycleScope.launch {
            viewModel.getNotice().collect{

                noticeAdapter.submitData(it)
            }
        }

        noticeAdapter.setOnItemClickListener(object :NoticeAdapter.OnItemClickListener{
            override fun onItemClick(position: Int, item: NoticeBeanItem) {

            }
        })

    }

    override fun initData() {

    }

}